package com.hecn.controller;

import com.hecn.pojo.User;
import com.sun.org.glassfish.gmbal.ParameterNames;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author 陈朋康
 * @site hecn.gitee.io
 * @discription
 */
@Controller
@RequestMapping("/user")
public class UserController {
    /**
     * @param name
     * @param model
     * @return  //localhost:8080/user/t1?name=xxx;
     */
    @GetMapping("/t1")
    public String test1(@RequestParam("username") String name, Model model) {
        //1.接受前端参数
        System.out.println("前端参数：" + name);
        //2.将返回的结果传递给前端
        model.addAttribute("msg", name);
        //3.视图跳转
        return "test";
    }

    /**
     * @param user
     * @return
     */
    @GetMapping("/t2")
    public String test2(User user){
        System.out.println(user);
        return "hello";
    }

    @GetMapping("/t3")
    public String test3(User user){
        System.out.println(user);
        return "hello";
    }
}
